package com.atguigu.hellomp.test;

import io.minio.BucketExistsArgs;
import io.minio.MinioClient;
import io.minio.UploadObjectArgs;
import io.minio.errors.*;

import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;

/**
 * author 张英杰
 * date 2025/10/8/周三 20:01
 */
public class T2 {
    public static void main(String[] args) throws ServerException, InsufficientDataException, ErrorResponseException, IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException {
        MinioClient minioClient = MinioClient.builder()
                .endpoint("http://192.168.109.130:9000")
                .credentials("minioadmin", "minioadmin")
                .build();

        BucketExistsArgs bucketExistsArgs = BucketExistsArgs.builder()
                .bucket("lease-0715")
                .build();


        boolean b = minioClient.bucketExists(bucketExistsArgs);
        System.out.println("=====================" + b + "=====================");

        UploadObjectArgs uploadObjectArgs = UploadObjectArgs.builder()
                .bucket("lease-0715")
                .filename("e:/107.jpg")     // filename是本地文件路径
                .object("a/107.jpg")    // object是上传到bucket下的路径
                .build();
        minioClient.uploadObject(uploadObjectArgs);

    }
}
